package com.yy.controller.mapper;

import com.github.pagehelper.Page;
import com.yy.dto.DishPageQueryDTO;
import com.yy.dto.EmployeePageQueryDTO;
import com.yy.entity.Dish;
import com.yy.entity.Employee;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 分页条件查询菜品信息
     * @param dishPageQueryDTO
     * @return
     */
    Page<Dish> pageList(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 新增菜品
     * @param dish
     */
    Long add(Dish dish);

    /**
     * 根据id修改菜品
     * @param dish
     */
    @Update("update dish set name = #{name}, category_id = #{categoryId},price = #{price},image = #{image}, status = #{status}," +
            "description = #{description},update_user = #{updateUser},update_time = #{updateTime} where id = #{id}")
    void update(Dish dish);

    /**
     * 根据id删除菜品
     * @param id
     */
    @Delete("delete from dish  where  id = #{id}")
    void delete(Long id);

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(*) from dish where category_id = #{categoryId}")
    Integer getByCategoryId(Long categoryId);

    /**
     * 根据id查菜品
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

    /**
     * 获取所有菜品
     * @return
     */
    @Select("select * from dish")
    List<Dish> getAllDish();

    /**
     * 根据categoryId查询在售菜品列表
     * @param categoryId
     * @return
     */
    @Select("select * from dish where category_id = #{categoryId} and status=1")
    List<Dish> dishListByCategoryIdandStatus(Long categoryId);
}
